class Solution:
    def minimumPerimeter(self, neededApples: int) -> int:
        now = 0
        ans = 0
        while now < neededApples:
            ans += 1
            now += (6 * ans) * (2 * ans)
        return ans * 8


if __name__ == "__main__":
    print(Solution().minimumPerimeter(1))  # 8
    print(Solution().minimumPerimeter(13))  # 16
    print(Solution().minimumPerimeter(1000000000))  # 5040
